<template>
  <div>
    <van-search v-model="value" placeholder="搜索商品,共3000+款好物" input-align="center" @focus="onfocus"/>
    <van-tabs>
      <van-tab title="推荐"></van-tab>
      <van-tab title="居家生活"></van-tab>
      <van-tab title="宠物生活"></van-tab>
      <van-tab title="服饰鞋包"></van-tab>
      <van-tab title="美食酒水"></van-tab>
      <van-tab title="个护清洁"></van-tab>
      <van-tab title="母婴亲子"></van-tab>
      <van-tab title="运动旅行"></van-tab>
      <van-tab title="数码家电"></van-tab>
      <van-tab title="严选全球"></van-tab>
    </van-tabs>
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="item in list" :key="item.id">
        <a :href="item.targetUrl"><img style="width: 100%" :src="item.picUrl" alt=""/></a>
      </van-swipe-item>
    </van-swipe>
    <p class="title">
      <span><i style="background-image: url('https://yanxuan.nosdn.127.net/a03dd909803b9ac032eba58b7253a2f6.png');"></i>网易自营品牌
      </span>
      <span><i style="background-image: url('https://yanxuan.nosdn.127.net/2d0402ffcd52b3ec3b07422681c42a89.png');"></i>30天无忧退换货
      </span>
      <span><i style="background-image: url('https://yanxuan.nosdn.127.net/eb61ee48e8942dbd1784c9ee75ebe955.png');"></i>48小时快速退款
      </span>
    </p>
    <van-grid :gutter="5" column-num="5" icon-size="46px" center>
      <van-grid-item :url="item.schemeUrl" v-for="item in list1" :key="item.text" :icon="item.picUrl"
                     :text="item.text"/>
    </van-grid>
    <van-grid direction="horizontal" :border="false" :column-num="3">
      <van-grid-item v-for="item in list2" :key="item.id">
        <a :href="item.targetUrl">
          <van-image :src="item.picUrl"/>
        </a>
      </van-grid-item>
    </van-grid>
    <div>
      <h3 style="font-weight: normal;text-align: center; line-height: 36px;height: 36px;">— 新人专享礼 —</h3>
      <div class="box">
        <div class="left">新人专享礼包
          <img src="https://yanxuan.nosdn.127.net/static-union/1648017994dd2933.png" alt=""></div>
        <div class="right">
          <div class="top">
            <p>福利社 <br>
              今日特价</p>
            <img
                src="https://yanxuan-item.nosdn.127.net/b6c1b1d3c7a6a1a40d92991d8cf01f0b.png?quality=75&type=webp&imageView&thumbnail=200x200"
                alt="">
          </div>
          <div class="bottom">新人拼团
            <img
                src="https://yanxuan-item.nosdn.127.net/4096900eff5679c558311cfc991d07e2.png?quality=75&type=webp&imageView&thumbnail=200x200"
                alt=""></div>
        </div>
      </div>
    </div>
    <h3 style="font-weight: normal;padding: 20px 20px;">类目热销榜</h3>
    <van-grid :gutter="2" column-num="3" icon-size="86px" center>
      <van-grid-item clickable v-for="item in list3" :key="item.categoryName" :icon="item.picUrl"
                     :text="item.categoryName"
                     :url="item.targetUrl"/>
    </van-grid>
    <div class="footer">
      <p>
        <span
            @click="getApp">下载app</span>
        <span
            @click="getPC">电脑版</span>
      </p>
      <p class="last">
        网易公司版权所有 © 1997-2023 <br>
        食品经营许可证：JY13301080111719
      </p>
    </div>
  </div>
</template>

<script lang="ts" setup>
import {getHomeList} from "@/hook/Home";
import {useCateList} from "@/hook/Category";

let {value, onfocus} = useCateList();
let {list, list1, list2, list3, getPC, getApp} = getHomeList();
</script>

<style lang='scss' scoped>
* {
  box-sizing: border-box;
}

.title {
  width: 100%;
  height: 50px;
  font-size: 14px;
  line-height: 24px;
  padding: 10px 2px;

  i {
    display: inline-block;
    width: 20px;
    height: 20px;
    vertical-align: middle;
    background-size: contain;
    margin-right: 6px;
  }
}

.footer {
  background: #414141;
  height: 162px;
  padding-top: 20px;

  p {
    display: flex;
    justify-content: space-around;
    font-size: 14px;
    margin-bottom: 16px;
    span {
      border-radius: 5px;
      color: #fff;
      display: inline-block;
      line-height: 24px;
      height: 24px;
      width: 80px;
      text-align: center;
      border: 1px solid #ccc;
    }
  }

  .last {
    color: gray;
  }
}

.box {
  display: flex;

  .left {
    display: inline-block;
    width: 50%;
    height: 100%;
    background: #F9E9CF;
    font-size: 20px;
    padding: 15px;
    text-align: center;

    img {
      margin-top: 20px;
      width: 80%;
      position: relative;
      right: 0;
    }
  }

  .right {
    display: inline-block;
    width: 50%;

    .top {
      height: 50%;
      background: #FBE2D3;
      position: relative;
      padding: 10px;

      img {
        width: 94px;
        height: 94px;
        float: right;
        position: absolute;
        right: 0;
        bottom: 0;
        top: 0;
        margin: auto;
      }
    }

    .bottom {
      height: 50%;
      background: #FFECC2;
      padding: 10px;
      position: relative;

      img {
        width: 94px;
        height: 94px;
        right: 0;
        position: absolute;
        bottom: 0;
        top: 0;
        margin: auto;
      }
    }
  }
}
</style>